import 'package:flutter_fronter_service/generated/json/base/json_convert_content.dart';
import 'package:flutter_fronter_service/model/cart_entity.dart';
import 'package:flutter_fronter_service/model/sku_entity.dart';


CartEntity $CartEntityFromJson(Map<String, dynamic> json) {
  final CartEntity cartEntity = CartEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    cartEntity.id = id;
  }
  final int? quantity = jsonConvert.convert<int>(json['quantity']);
  if (quantity != null) {
    cartEntity.quantity = quantity;
  }
  final SkuEntity? skuEntity = jsonConvert.convert<SkuEntity>(
      json['skuEntity']);
  if (skuEntity != null) {
    cartEntity.skuEntity = skuEntity;
  }
  final String? spec = jsonConvert.convert<String>(json['spec']);
  if (spec != null) {
    cartEntity.spec = spec;
  }
  return cartEntity;
}

Map<String, dynamic> $CartEntityToJson(CartEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['quantity'] = entity.quantity;
  data['skuEntity'] = entity.skuEntity.toJson();
  data['spec'] = entity.spec;
  return data;
}

extension CartEntityExtension on CartEntity {
  CartEntity copyWith({
    int? id,
    int? quantity,
    SkuEntity? skuEntity,
    String? spec,
  }) {
    return CartEntity()
      ..id = id ?? this.id
      ..quantity = quantity ?? this.quantity
      ..skuEntity = skuEntity ?? this.skuEntity
      ..spec = spec ?? this.spec;
  }
}